//      main.c
//      
//      Copyright 2011 DJ Shaji <djshaji@gmail.com>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/reboot.h>

#include "message.h"

int main ( int argc, char * argv [] )
{
	message_print_banner () ;
	message ( "Running setup ...\n", MESSAGE_INFO ) ;
	
	devices_mount_core () ;
	kernel_set_loglevel ( 1 ) ;
	
	devices_mount_storage () ;
	
	devices_mknod_alsa () ;
	kernel_set_loglevel ( 5 ) ;
	
	struct stat st ;
	
	if ( stat ( "/usr/rc", & st ) == 0 )
		execl ( "/usr/rc", "/usr/rc", NULL );
	else
	{
		message ( "Setup could not find an april installation !\n\n"
				  "\tSystem halted.\n"
				  "\tPress enter to reboot.",
				  MESSAGE_ABORT ) ;
		fgetc ( stdin ) ;
		
		/** But I'm a REAL programmer ! **/
		reboot ( 0x01234567 ) ;
	}
	
	pause () ;
	
}
